<template>
	<view>
		<!-- 企业信息 -->
		<view style="padding-bottom: 20rpx;">
			<view v-for="(item,index) in listData">
				<!-- 基本信息 -->
				<view class="list_item" @click="itemClick(item)">
					<view class="item_top">
						<text class="top_left">{{item.warningInfo}}</text>
					</view>

					<view class="item_top">
						<text class="top_left" style="font-size: 26rpx;color: #CA2828;">{{item.ownerName}}</text>
						<text class="bottom_center" style="font-size: 26rpx;color: #999999;">{{item.warningTime}}</text>
					</view>

					<view class="item_top">
						<text class="top_left" style="font-size: 26rpx;color: #1590EF;">{{item.warningTypeDesc}}</text>
						<text class="top_right"
							style="color: #757575;font-size: 26rpx;">{{item.warningCategoryStr}}</text>
					</view>
				</view>

			</view>
		</view>
	</view>
</template>

<script>
	import {
		warningPage
	} from '@/common/api/req.js'
	export default {
		props: ['dataList'],
		components: {},
		data() {
			return {
				chartData: {},
				//您可以通过修改 config-ucharts.js 文件中下标为 ['ring'] 的节点来配置全局默认参数，如都是默认参数，此处可以不传 opts 。实际应用过程中 opts 只需传入与全局默认参数中不一致的【某一个属性】即可实现同类型的图表显示不同的样式，达到页面简洁的需求。
				opts: {
					rotate: false,
					rotateLock: false,
					color: ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4",
						"#ea7ccc"
					],
					padding: [5, 5, 5, 5],
					dataLabel: true,
					legend: {
						show: true,
						position: "bottom",
						lineHeight: 25
					},
					title: {
						name: "",
						fontSize: 15,
						color: "#666666"
					},
					subtitle: {
						name: "",
						fontSize: 25,
						color: "#7cb5ec"
					},
					extra: {
						ring: {
							ringWidth: 60,
							activeOpacity: 0.5,
							activeRadius: 10,
							offsetAngle: 0,
							labelWidth: 15,
							border: false,
							borderWidth: 3,
							borderColor: "#FFFFFF"
						}
					}
				},
				listData: [],
				current: 1,
				size: 10,
				isloading: false,
				pieData: [{
					"name": "证照超期",
					"value": 0
				}, {
					"name": "异地经营",
					"value": 0
				}, {
					"name": "安全运营",
					"value": 0
				}],
				// options: {},
				ownerName: "",
				warningType: "",
				tablePages: {
					current: 1,
					size: 10,
					total: 0,
				},
			};
		},
		onLoad(option) {
			// this.options = option.data
			// this.ownerName = option.ownerName
			// this.warningType = option.warningType
			// if (option.data) {
			// 	this.listData = JSON.parse(option.data)
			// }
		},
		mounted() {
			this.search(this.dataList)
		},

		onReady() {
			this.getServerData();
		},
		methods: {
			search(item) {
				const formData = {
					ownerName: item.inspObjName ? item.inspObjName : "",
					warningType: item.warningType ? item.warningType : "",
					...this.tablePages
				}
				warningPage(formData)
					.then((res) => {
						this.listData = res.data.data.records
					})
			},
			getpieCharts() {
				pieCharts({}).then(res => {
					let warningAqyyCount = res.data.data.warningAqyyCount
					let warningYdyyCount = res.data.data.warningYdyyCount
					let warningZjcqCount = res.data.data.warningZjcqCount

					let sumCount = parseInt(warningAqyyCount) + parseInt(warningYdyyCount) + parseInt(
						warningZjcqCount)


					this.opts.subtitle.name = sumCount + "条"
					let AqyyCount = parseInt(warningAqyyCount) / sumCount
					let YdyyCount = parseInt(warningYdyyCount) / sumCount
					let ZjcqCount = parseInt(warningZjcqCount) / sumCount
					this.pieData = [{
						"name": "证照超期",
						"value": ZjcqCount
					}, {
						"name": "异地经营",
						"value": YdyyCount
					}, {
						"name": "安全运营",
						"value": AqyyCount
					}]
				})
			},

			getServerData() {
				//模拟从服务器获取数据时的延时
				setTimeout(() => {
					//模拟服务器返回数据，如果数据格式和标准格式不同，需自行按下面的格式拼接
					let res = {
						series: [{
							data: this.pieData
						}]
					};
					this.chartData = JSON.parse(JSON.stringify(res));
				}, 500);
			},

			itemClick(item) {
				this.$goBack('./warningDetails?item=' + encodeURIComponent(JSON.stringify(item)), 2);
			},
			replaceClick() {
				if (this.isShow) {
					this.isShow = false
					this.msgtoast = '切换列表'
				} else {
					this.isShow = true
					this.msgtoast = '切换图标'
				}
			}
		}
	}
</script>

<style lang="scss">
	.list_item {
		border-radius: 10px;
		background-color: #FFFFFF;
		margin: 10px 20px 0 20px;
		padding-bottom: 5px;
		padding: 10px;

		.item_top {
			margin-bottom: 14rpx;
			width: 100%;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.top_left {
				font-size: 16px;

			}

			.top_right {
				font-size: 13px;
				color: #1590EF;
			}
		}

		.item_bottom {
			width: 100%;
			display: flex;
			margin-top: 10px;
			align-items: center;
			justify-content: space-around;

			.bottom_left {
				font-size: 13px;
				color: #CA2828;
			}


			.bottom_center {
				font-size: 13px;
				color: #999999;
			}

			.bottom_right {
				font-size: 13px;
				color: #333333;
			}
		}
	}
</style>
